package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strings"
)

func main() {
	file, err := os.Open("E:\\BaiduYunDownload\\CSDN-中文IT社区-600万.sql")

	defer file.Close()
	if err != nil {
		fmt.Println("文件读取失败", err)
		return
	}

	path := "D:\\go\\csdnemail.txt"
	saveFile, err := os.Create(path)
	defer saveFile.Close()

	save := bufio.NewWriter(saveFile)

	bd := bufio.NewReader(file)

	for {
		line, _, err := bd.ReadLine() // 读取一行

		if err == io.EOF {
			break
		}

		linestr := string(line)
		strArr := strings.Split(linestr, "#")
		//fmt.Println(strArr[0], strArr[1])

		fmt.Fprintln(save, strings.TrimSpace(strArr[2]))

	}

	save.Flush()
}
